/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ReportPnl.java
 *
 * Created on Jul 23, 2011, 12:01:32 AM
 */
package com.viweb.storemanager.report;

import com.viweb.storemanager.dao.Biz;
import com.viweb.storemanager.entity.Category;
import com.viweb.storemanager.entity.Customer;
import com.viweb.storemanager.entity.Employee;
import com.viweb.storemanager.entity.Product;
import com.viweb.storemanager.entity.Vendor;
import com.viweb.storemanager.ui.MainFrm;
import java.awt.FlowLayout;
import java.util.ArrayList;
import javax.swing.JPanel;

/**
 *
 * @author Wind
 */
public class ReportPnl extends javax.swing.JPanel {

    MainFrm main;

    /** Creates new form ReportPnl */
    public ReportPnl(int selector, JPanel own, MainFrm main) {
        initComponents();
        this.main = main;
        ReportManager reportManager = new ReportManager(main.APP_CONFIG.getInfoConfig());
        JPanel report = null;
        switch (selector) {
            case 1: // Customer

                ArrayList<Customer> customers = Biz.getInstance().selectAllCustomer();

                report = reportManager.getCustomerDetailsViewer(customers);
                setLayout(new FlowLayout());
                this.add(report);
                break;
            case 2: //Vendor
                ArrayList<Vendor> vendors = Biz.getInstance().selectAllVendor();

                report = reportManager.getVendorDetailsViewer(vendors);
                setLayout(new FlowLayout());
                this.add(report);
                break;
            case 3: //Employee
                ArrayList<Employee> emps = Biz.getInstance().selectAllEmployee();
                setLayout(new FlowLayout());
                report = reportManager.getEmployeeDetailsViewer(emps);
                this.add(report);
                break;
            case 4: // Category
                ArrayList<Category> categories = Biz.getInstance().selectAllCategory();
                setLayout(new FlowLayout());
                report = reportManager.getTypeProductDetailsViewer(categories);
                this.add(report);
                break;
            case 5: // Product
                ArrayList<Product> products = Biz.getInstance().selectAllProduct();
                ArrayList<Category> categoriesList = Biz.getInstance().selectAllCategory();
                report = reportManager.getProductDetailsViewer(products, categoriesList);
                setLayout(new FlowLayout());
                this.add(report);
                break;
            default:

        }

        report.setSize(own.getSize());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
